#ifndef QIPAN_H
#define QIPAN_H

#include <QObject>
#include<QPaintEvent>
#include<QPainter>
#include<QWidget>
#include<QVector>
#include"stdshared.h"
#include<stack>



class qipan : public QWidget
{
    Q_OBJECT
public:
    explicit qipan(QWidget *parent = nullptr);

    /*记录棋盘位置对应的玩家*/
    void setBoardInfo(int row,int col ,Role role);
    /*得到棋盘的信息*/
    Role **getBoardInfo(int &boardSize);

    /*清空棋盘*/
    void resetBoard();
protected:
    /*绘画事件*/
    void paintEvent(QPaintEvent *event);
    /*鼠标移动事件*/
    void mouseMoveEvent(QMouseEvent *event);
    /*鼠标点击事件*/
    void mousePressEvent(QMouseEvent *event);

signals:
    /*发送落子信号*/
    void chessClick(int row,int col);
public slots:
    void onGameStartedChanged(bool started);  // 接收游戏开始状态改变的槽函数
    void undoMove();//悔棋


private:
   static const int m_boardSize=15;
   static const int m_cellSize=40;
   static const int m_margin=m_cellSize/2;
   /*玩家是1，人机是2*/
    Role **m_board;
    bool gameStarted;




   /*悬停坐标*/
   int m_hoverRow;
   int m_hoverCol;
   bool m_hoverFlag;

   std::stack<Move> moveHistory;







public slots:
};

#endif // QIPAN_H
